package admin

import (
	models "HeadLineNews/proto_models/manage/admin_model"
	"HeadLineNews/utils"
	"github.com/gin-gonic/gin"
)

type Ctx interface {
	ParseParamAdminRegister(c *gin.Context) (p *models.RequestAdminRegister, err error)
	ParseParamAdminLogin(c *gin.Context) (p *models.RequestAdminLogin, err error)

	ParseParamListAdmin(c *gin.Context) (p *models.RequestListAdmin, err error)
}

type ctx struct{}

func NewCtx() Ctx {
	return &ctx{}
}

// ParseParamAdminRegister 解析管理员登录参数
func (ctx *ctx) ParseParamAdminRegister(c *gin.Context) (p *models.RequestAdminRegister, err error) {
	p = new(models.RequestAdminRegister)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamAdminLogin 解析管理员登录参数
func (ctx *ctx) ParseParamAdminLogin(c *gin.Context) (p *models.RequestAdminLogin, err error) {
	p = new(models.RequestAdminLogin)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamListAdmin 解析展示管理员的参数
func (ctx ctx) ParseParamListAdmin(c *gin.Context) (p *models.RequestListAdmin, err error) {
	p = new(models.RequestListAdmin)
	err = utils.ShouldBindProtobuf(c, p)
	return
}
